﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Report
{
    public partial class ReportForm : Form
    {
        public ReportForm()
        {
            InitializeComponent();
            var reportManger = new ReportManager();
            var list = reportManger.BuildReportList(DbProvider.Data,string.Empty);
            reportManger.InitializeGridView2(dataGridView1,list);
        }
        public ReportForm(IList<IItem> datas)
        {
            InitializeComponent();

            var reportManger = new ReportManager();
            reportManger.InitializeGridView2(dataGridView1, datas);
        }
        private void button1_Click(object sender, EventArgs e)
        {
             printPreviewDialog1.Document = printDocument1;
             printPreviewDialog1.PrintPreviewControl.Zoom = 1;
             printPreviewDialog1.ShowDialog();
        }

        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
             Bitmap dataGridViewImage = new Bitmap(this.dataGridView1.Width, this.dataGridView1.Height);
             dataGridView1.DrawToBitmap(dataGridViewImage, new Rectangle(0, 0, this.dataGridView1.Width, this.dataGridView1.Height));
             e.Graphics.DrawImage(dataGridViewImage, 0, 0);
        }

      
    }
}
